package workplace

import (
	"ginfwk/infrastructure/helper/ghttp"
	"github.com/gin-gonic/gin"
	"time"
)

type Workplace struct {
}

// Total 用户来源
// url:/admin/workplace/total
func (u *Workplace) Total(g *gin.Context) interface{} {
	type AnalysisTotal struct {
		Project int `json:"project"`
		Access  int `json:"access"`
		Todo    int `json:"todo"`
	}

	res := AnalysisTotal{
		Project: 40,
		Access:  2340,
		Todo:    10,
	}
	return ghttp.Success(res)
}

// Radar 用户来源
// url:/admin/workplace/radar
func (u *Workplace) Radar(g *gin.Context) interface{} {
	type AnalysisRadar struct {
		Name     string `json:"name"`
		Max      int    `json:"max"`
		Personal int    `json:"personal"`
		Team     int    `json:"team"`
	}

	res := []AnalysisRadar{
		{Name: "workplace.quote", Max: 65, Personal: 42, Team: 50},
		{Name: "workplace.contribution", Max: 160, Personal: 30, Team: 140},
		{Name: "workplace.hot", Max: 300, Personal: 20, Team: 28},
		{Name: "workplace.yield", Max: 130, Personal: 35, Team: 35},
		{Name: "workplace.follow", Max: 100, Personal: 80, Team: 90},
	}
	return ghttp.Success(res)
}

// Dynamic 用户来源
// url:/admin/workplace/dynamic
func (u *Workplace) Dynamic(g *gin.Context) interface{} {
	type Item struct {
		Keys []string  `json:"keys"`
		Time time.Time `json:"time"` // 2023-12-20T16:59:42.001Z
	}

	res := []Item{
		{
			Keys: []string{"workplace.push", "Github"},
			Time: time.Now(),
		},
		{
			Keys: []string{"workplace.push", "Github"},
			Time: time.Now(),
		},
		{
			Keys: []string{"workplace.push", "Github"},
			Time: time.Now(),
		},
		{
			Keys: []string{"workplace.push", "Github"},
			Time: time.Now(),
		},
		{
			Keys: []string{"workplace.push", "Github"},
			Time: time.Now(),
		},
		{
			Keys: []string{"workplace.push", "Github"},
			Time: time.Now(),
		},
	}
	return ghttp.Success(res)
}

// Project 用户来源
// url:/admin/workplace/project
func (u *Workplace) Project(g *gin.Context) interface{} {
	type AnalysisTotal struct {
		Users     int `json:"users"`
		Messages  int `json:"messages"`
		Moneys    int `json:"moneys"`
		Shoppings int `json:"shoppings"`
	}
	type AnalysisProject struct {
		Name     string    `json:"name"`
		Icon     string    `json:"icon"`
		Message  string    `json:"message"`
		Personal string    `json:"personal"`
		Time     time.Time `json:"time"`
	}

	res := []AnalysisProject{
		{
			Name:     "Github",
			Icon:     "akar-icons:github-fill",
			Message:  "workplace.introduction",
			Personal: "Archer",
			Time:     time.Now(),
		},
		{
			Name:     "Vue",
			Icon:     "logos:vue",
			Message:  "workplace.introduction",
			Personal: "Archer",
			Time:     time.Now(),
		},
		{
			Name:     "Angular",
			Icon:     "logos:angular-icon",
			Message:  "workplace.introduction",
			Personal: "Archer",
			Time:     time.Now(),
		},
		{
			Name:     "React",
			Icon:     "logos:react",
			Message:  "workplace.introduction",
			Personal: "Archer",
			Time:     time.Now(),
		},
		{
			Name:     "Webpack",
			Icon:     "logos:webpack",
			Message:  "workplace.introduction",
			Personal: "Archer",
			Time:     time.Now(),
		},
		{
			Name:     "Vite",
			Icon:     "vscode-icons:file-type-vite",
			Message:  "workplace.introduction",
			Personal: "Archer",
			Time:     time.Now(),
		},
	}
	return ghttp.Success(res)
}

// Team 用户来源
// url:/admin/workplace/team
func (u *Workplace) Team(g *gin.Context) interface{} {
	type AnalysisTotal struct {
		Users     int `json:"users"`
		Messages  int `json:"messages"`
		Moneys    int `json:"moneys"`
		Shoppings int `json:"shoppings"`
	}
	type AnalysisItem struct {
		Name string `json:"name"`
		Icon string `json:"icon"`
	}

	res := []AnalysisItem{
		{
			Name: "Github",
			Icon: "akar-icons:github-fill",
		},
		{
			Name: "Vue",
			Icon: "logos:vue",
		},
		{
			Name: "Angular",
			Icon: "logos:angular-icon",
		},
		{
			Name: "React",
			Icon: "logos:react",
		},
		{
			Name: "Webpack",
			Icon: "logos:webpack",
		},
		{
			Name: "Vite",
			Icon: "vscode-icons:file-type-vite",
		},
	}
	return ghttp.Success(res)
}
